<?php 
require "DataLoad.php"; 
?>
<!DOCTYPE html PUBLIC "-//W3C//Dth XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/Dth/xhtml1-transitional.dth">
<html>
<head>
<title><?php echo $GuildName;?> - DKP系统</title>
<script language="JavaScript" src="inc/jquery.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="Generator" content="EditPlus">
<meta name="Author" content="SULei">
<meta name="Keywords" content="魔兽世界DKP系统 DKP程序 公会DKP">
<meta name="Description" content="">
<link href="<?php echo $StylePath;?>/main.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="<?php echo $StylePath;?>/styleplus.js"></script>
<style type="text/css" media="all">

</style>
<?php require "inc/ajax.php"; ?>
</head>

<body>
<div class="header">
<?php require "menu.php"; ?>
</div>
<div class="main">
<?php if ($_GET["action"]=="Search") Search(); ?>
<div class="SearchFrame outframe">
	<h3>DKP查询</h3>
<form method=post action="?action=Search">
	<input class="inp" type="text" name="keyword" value=""><input class="btn" type="submit" value="查询">
	<?php if ($SearchError!="") { print "<br><b>".$SearchError."</b>";} ?>
</form>
</div>
<?php 

switch ($_GET["filter"]) {
	case "战士":
	playerlist("select * from player where player_class='战士' order by player_name");
	break;
	case "法师":
	playerlist("select * from player where player_class='法师' order by player_name");
	break;
	case "牧师":
	playerlist("select * from player where player_class='牧师' order by player_name");
	break;
	case "盗贼":
	playerlist("select * from player where player_class='盗贼' order by player_name");
	break;
	case "猎人":
	playerlist("select * from player where player_class='猎人' order by player_name");
	break;
	case "德鲁伊":
	playerlist("select * from player where player_class='德鲁伊' order by player_name");
	break;
	case "术士":
	playerlist("select * from player where player_class='术士' order by player_name");
	break;
	case "圣骑士":
	playerlist("select * from player where player_class='圣骑士' order by player_name");
	break;
	case "死亡骑士":
	playerlist("select * from player where player_class='死亡骑士' order by player_name");
	break;
	case "萨满祭司":
	playerlist("select * from player where player_class='萨满祭司' order by player_name");
	break;
	case "按出场次数":
	playerlist("select * from player order by player_raidNum desc");

	break;
	case "按种族":
	playerlist("select * from player order by player_race desc");
	break;
	case "分霸":
	playerlist("select top 10 * from player order by player_DKP desc");
	break;
	case "失踪人员名单":
	playerlist("select top 50 * from player order by player_lastraid");
	break;
	case "all":
	playerlist("select * from player order by player_name");
	break;
	default:

	playerlist("");

	break;
} 

view_playerpro();
?>
</div>
<?php require "footer.php"; ?>

<script language="JavaScript">
	$("input[name=keyword]").focus(
		function () {
			if (this.value == "输入完整的角色名字") {
				this.attr("value","")
			};
		});
	

</script>

</body>
</html>
<?php 
function ClassIconMenu($strSelected) {
	global $ArrTF, $langcode;
	$isActived=false;
	$html .= "<div class='IconMenu'>";
	foreach ($ArrTF as $row) {
		if ($strSelected==$row[0]) {
			$html .= "<a href='?' class='icobtn selected'><img src='images/icon/".$row[2].".png' alt='".$row[$langcode]."' />".getClassMemberCount($row[0])."</a>";
			$isActived=true;
		}else{
			$html .= "<a href='?filter=".rawurlencode($row[0])."' class='icobtn'><img src='images/icon/".$row[2].".png' alt='".$row[$langcode]."' />".getClassMemberCount($row[0])."</a>";
		} 
	}

	if ($isActived==true) {
		$html .= " <a href='?' class='abtn'>显示全部职业</a>";
	} 
	$html .= "</div>";
	return $html;
} 


function playerlist($s) {
	if ($s=="") {
		$s="select * from player order by player_lastraid desc";
	} 

	$sql=$s;
	$result = mysql_query($sql);
	if (mysql_num_rows($result) > 99) {
		print "<div class='message'><span>本页只显示了最近参加活动的前100人名单,点击<a href='player.php?filter=all'>显示全部成员</a></span></div>";
	} 
	print "<table class='playerlist outframe interlace'><tr><th colspan='9'><div class='title'><img src='images/icon/axe.jpg' width='64' height='64' border=0 alt=''>成员列表</div></th></tr>";
	print "<tr><td colspan='6'>".ClassIconMenu($_GET['filter'])."</td></tr>";
	print "<tr class='coltitle'><td>Name</td><td width='100px'>".selectDKPclass()."</td><td>职衔</td><td>出场</td><td>最近一次</td><td width='50%'>装备获得</td></tr>";
	if (mysql_num_rows($result) == 0) {
		print "<tr><td colspan='9'>None</td></tr>";
	}else{
		while ($row = mysql_fetch_array($result)) {
			print "<tr><td><img src='".getProfessionSmallIco($row["player_class"])."' alt=".$row["player_class"]." /> <img src='".getRaceSmallIco($row["player_race"])."' alt=".$row["player_race"]." /> <a href='player_detail.php?id=".$row["id"]."' name='playername'>".$row["player_name"]."</a></td>";
			print "<td class='dkp'>/</td>";
			print "<td>".$row["player_guildlevel"]."</td>";
			print "<td>".$row["player_raidnum"]."</td>";
			print "<td>".time_type($row["player_lastraid"],3)."</td>";
			print "<td>".getLootItemsLink($row["player_looted"])."</td>";
			print "</tr>"."\r\n";
		}
	} 
	print "</table>";
	return true;
}


function selectDKPclass() {
	$sql="Select * from Raid_class";
	if ($result = mysql_query($sql)) {
	$html = "<select name='dkpClassSelect'>";
	$html .= "<option value=''>选择DKP分类</option>";
		while ($row = mysql_fetch_array($result)) {
			$html .= "<option value='".$row["id"]."'>".$row["class_name"]."</option>";
		}
	$html .= "</select>";
	}else{
		return '无DKP分类';
	}
	return $html;
} 


function view_playerpro() {
	//职业比例
	$j=0;
	$sql="select * from player order by player_class desc";
	if ($result = mysql_query($sql)) {
		return false;
	}else{
		$allcount=$result->recordcount;
		while ($row = mysql_fetch_array($result)) {
			if ($arrName[$j]!=$row["player_class"]) {
				$j=$j+1;
				$arrNum[$j]=1;
				$arrName[$j]=$row["player_class"];
			}else{
				if ($datediff["d"][$row["player_lastraid"]][time()]<$activityday) {
					$arrANum[$j]=$arrANum[$j]+1;
					$allAcount=$allAcount+1;
				} 
				$arrNum[$j]=$arrNum[$j]+1;
			}
		}
	}
	print "<div class='outframe' id='proview'><h3>职业比率 ( 目前共 ".$allcount." 人,其中 ".$allAcount." 人近".$activityday."天内活跃 , 公会活力 ".intval($allAcount/$allcount*100)."% )</h3><ul>";
	for ($i=1; $i<=12; $i=$i+1) {
		if ($arrName[$i]=="" || $arrName[$i]=="未知") {
		}else{
			print "<li>".$arrName[$i].":".$arrNum[$i]."人 活跃:".$arrANum[$i]."<img src='".$StylePath."/images/ga.gif' width='".intval($arrNum[$i]/$allcount*200)."%' height='16px'><img src='".$StylePath."/images/gall.gif' width='".intval($arrANum[$i]/$allcount*200)."%' height='16px'></li>";
		} 
	}
	print "</ul></div>";
	return $function_ret;
} 

?>
